package com.youdianda.controller.user;


import com.youdianda.dto.EditArticleDTO;
import com.youdianda.dto.MyArticleDTO;
import com.youdianda.dto.UserDataListDTO;
import com.youdianda.entity.YddArticle;
import com.youdianda.result.Result;
import com.youdianda.service.IYddArticleService;
import com.youdianda.service.IYddCateService;
import com.youdianda.service.UserMyArticleService;
import com.youdianda.vo.PageResult;
import com.youdianda.vo.UserDataListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 我的文章
 */

@RestController
@RequestMapping("/user")
public class UserMyArticleController {


    @Autowired
    private IYddArticleService yddArticleService;

    @Autowired
    private UserMyArticleService userMyArticleService;


    /**我的文章
     * @return
     */
    @GetMapping("myArticle")
    public Result<PageResult> myArticle(MyArticleDTO myArticleDTO) {
        return yddArticleService.myArticle(myArticleDTO);
    }

    /**
     *  我的收藏/点赞文章
     * @param userDataListDTO
     * @return
     */
    @GetMapping("/userDataList")
    public Result<UserDataListVO> userDataList( UserDataListDTO userDataListDTO){
        return yddArticleService.userDataList(userDataListDTO);
    }


    /**
     * 修改文章
     * @return
     */
    @PostMapping("/editArticle")
    public Result editArticle(@RequestBody EditArticleDTO articleDTO){
        return Result.success(articleDTO);
    }

    /**
     * 发布文章
     * @param yddArticle
     * @return
     */
    @PostMapping("/addArticle")
    public Result addArticle(@RequestBody YddArticle yddArticle){
        return userMyArticleService.addArticle(yddArticle);
    }

    /**
     * 删除我的文章
     * @return
     */
    @GetMapping("/delArticle")
    public Result deleteArticle(Integer id){
        return userMyArticleService.deleteArticle(id);
    }

}
